import React,{useState} from 'react'
import { Stepper } from 'antd-mobile'

export default function Controll({ updateCart, productPrice }) {
  const [quantity, setQuantity] = useState(0)
  const handleChange = (value) => {
    if(value<0)return //防止数量变为负数
    setQuantity(value)
    updateCart(productPrice,value-quantity) //计算数量的差值
  }
  return (
    <div>
      <Stepper
        style={{ width: '80px', height: '20px' }}
       value={quantity}
        min={0}
        onChange={handleChange}
      />
    </div>
  )
}
